package com.luoying.itew.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.luoying.itew.R;

import java.util.List;

/**
 * Created by lufan on 2019-05-08
 * Class describe
 */
public class DetaiImgAdapter extends RecyclerView.Adapter<DetaiImgAdapter.ViewHoler>  {
    private List<String> imgList;
    private Context context;

    public DetaiImgAdapter(List<String> imgList, Context context) {
        this.imgList = imgList;
        this.context = context;
    }

    @NonNull
    @Override
    public ViewHoler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_detail_img,parent,false);
        return new ViewHoler(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHoler holder, int position) {
        //加载图片
        Glide.with(context)
                .load(imgList.get(position))
                .into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return imgList.size();
    }

    class ViewHoler extends RecyclerView.ViewHolder {
        public ImageView imageView;
        public ViewHoler(View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.item_detail_img);
        }
    }
}
